from PyQt5 import QtWidgets
from PyQt5 import QtCore
from PyQt5 import QtGui

import sys

class QMessageBoxTest(QtWidgets.QWidget):
    def __init__(self, parent=None):
        super(QMessageBoxTest, self).__init__(parent)

        self.setWindowTitle("QMessageBoxTest例子")

        self.resize(300, 100)

        self.info_button = QtWidgets.QPushButton(self)
        self.info_button.setText("点击弹出信息框")
        self.info_button.clicked.connect(self.show_information_message_box)

    def show_information_message_box(self):
        reply = QtWidgets.QMessageBox.information(self, "标题", "消息正文", QtWidgets.QMessageBox.Yes | QtWidgets.QMessageBox.No, QtWidgets.QMessageBox.Yes)
        if reply == QtWidgets.QMessageBox.Yes:
            print("用户同意")
        else:
            print("用户拒绝")

if __name__ == '__main__':
    app = QtWidgets.QApplication(sys.argv)
    QtWidgets.QApplication.setStyle("Fusion")
    win = QMessageBoxTest()
    win.show()
    sys.exit(app.exec_())